#ifndef __HIRESTIME_H__
#define __HIRESTIME_H__

#ifdef _WIN32
#include <tchar.h>
#include <windows.h>

typedef LARGE_INTEGER HRTTime;

static HRTTime m_freq;
static HRTTime m_beginTime;
static HRTTime m_crtTime;

void HRTInit()
{
    QueryPerformanceFrequency(&m_freq);
    QueryPerformanceCounter(&m_beginTime);
}

double HRTNowSec()
{
    QueryPerformanceCounter(&m_crtTime);
    return (double)(m_crtTime.QuadPart-m_beginTime.QuadPart)/m_freq.QuadPart;
}

HRTTime HRTNow()
{
    QueryPerformanceCounter(&m_crtTime);
    return m_crtTime;
}

#endif 
//eof _WIN32

#ifdef __unix__
#include <time.h>

typedef clock_t HiResTime;

static HiResTime m_beginTime;
static HiResTime m_crtTime;

void HRTInit()
{
    m_beginTime = clock();
}

double HRTNowSec()
{
    m_crtTime = clock();
    return (double) m_crtTime / 100.0;
}
         
HiResTime HRTNow()
{
    m_crtTime = clock();
    return m_crtTime * 10.0;
}
#endif 
//eof __linux__

#endif

